package top.codecrab.springcloud.entity.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author codecrab
 * @since 2021年05月14日 10:14
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    private Integer code;

    private String message;

    private Object data;

    public Result(Integer code, String message) {
        this(code, message, null);
    }

    public static Result ok() {
        return new Result(200, "操作成功");
    }

    public static Result ok(Object data) {
        return new Result(200, "操作成功", data);
    }

    public static Result ok(String message, Object data) {
        return new Result(200, message, data);
    }

    public static Result fail() {
        return new Result(444, "操作失败", null);
    }

    public static Result fail(String message) {
        return new Result(444, message, null);
    }
}
